/**
 * 
 */
package neptune.web.client.view.components.editor;

import neptune.web.client.model.topology.SerializableNetworkInterface;
import neptune.web.client.model.topology.SerializableNode;
import neptune.web.client.model.topology.SerializableTopology;

import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.TreeItem;

/**
 * @author Roberto Bifulco [RobertoBifulco.it] [info@robertoBifulco.it]
 * 
 */
public class NetworkIFMenuBar extends MenuBar {

	protected MenuItem mainItem;

	public NetworkIFMenuBar(SerializableNetworkInterface netIF,
			SerializableNode node, SerializableTopology topology, TreeItem item) {
		super(false);

		MenuItem props = new MenuItem("Properties", new NetIFPropsCommand(
				netIF, node, topology, item));
		MenuItem addIp = new MenuItem("Add IP Address", new AddIpAddrCommand(
				netIF, item));
		MenuItem removeNode = new MenuItem("Remove", new RemoveNetIFCommand(
				netIF, node, item));

		MenuBar options = new MenuBar(true);

		options.addItem(props);
		options.addItem(addIp);
		options.addItem(removeNode);

		mainItem = new MenuItem(netIF.getInterfaceName(), options);
		addItem(mainItem);
		options.setStylePrimaryName("TopologyEditor-tree-NodeItem");
		this.setStylePrimaryName("TopologyEditor-tree-RootNodeItem");
	}

	public MenuItem getRootItem() {
		return mainItem;
	}

	public void setText(String text) {
		mainItem.setText(text);
	}
}
